<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr = [1, 2, 3, 4, 5];

      let res = arr.reduce((a, b) => {
        return a + b;
      }, 10);
      console.log(res);
      //  demo 统计元素出现的次数
      let a = [1, 2, 3, 1, 13, 1, 1, 1];
      function getCount(array, item) {
        return array.reduce((a, b) => {
          return (a += b == item ? 1 : 0);
        }, 0);
      }
      console.log(getCount(a, 1));
    </script>
  </body>
</html>
